package com.coderju.dao;

import com.coderju.domain.User;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.junit.jupiter.api.Test;

public class UserDao {

    public static User findByUsername(String username){
        SAXReader saxReader = new SAXReader();
        try {
           Document doc =  saxReader.read("G:\\workspaces\\JavaStudy\\LoginDemo\\src\\main\\resources\\User.xml");
           Element el = (Element) doc.selectSingleNode("//user[@username='"+username+"']");
           String  attrUsername = el.attributeValue("username");
            System.out.println(attrUsername);
        } catch (DocumentException e) {
            e.printStackTrace();
        }


        return null;
    }

    public static void main(String[] args) {
        findByUsername("张三");
    }

    public void add(User user){

    }
}
